| 值 | 意義 | 
|---|---|
| 0 | 低電位(邏輯0) | 
| 1 | 高電位(邏輯1) | 
| Z | 高阻抗(High Impendence ) | 
| X | 未知的值((Unknow)or邏輯衝突) | 
z
module test(
  a, 
  b, 
  m, 
  n
);
input a;
input b;
output m;
output n;
wand m;
wor n;
    
// wire and ---> m = a&b
assign m = a;
assign m = b;
// wire or ---> n = a|b
assign n = a;
assign n = b;
endmodule
module test(
  clk, 
  rst_n, 
  a, 
  b
);
input clk;
input a;
input rst_n;
output b;
reg b;
    
always@(posedge clk or negedge rst_n)begin
  if(!rst_n)b <= 1'b0;
  else      b <= a;
end
    
endmodule
到這邊後,應該有些人對於 reg 與 wire 的使用不是很理解,先來解釋位甚麼第二個例子需要用 reg 型態,
因為變數 b 在 alwaye 內賦值,而 always 又是屬於觸發型電路,所以需要用暫存器儲存"前態"與"次態",是不可用 wire 的(wire 沒有記憶性),順帶一提,這邊的 reset 如果是負緣,那我們通常會加個 _n ,讓別人知道那是負緣觸發,若是正緣的話則不用加,這樣的 coding-style 是比較好的!!